<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
    <meta name="author" content="火星科技 http://mars3d.cn " />
    <meta name="apple-touch-fullscreen" content="yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="x5-fullscreen" content="true" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <!-- 标题及搜索关键字 -->
    <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
    <meta
      name="description"
      content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型  gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包  地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
    />

    <link rel="shortcut icon" type="image/x-icon" href="http://mars3d.cn/favicon.ico" />
    <title>三维地图 | Mars3D | 三维地图 | 火星科技 | 合肥火星科技有限公司</title>

    <!--第三方lib-->
    <script
      type="text/javascript"
      src="../lib/include-lib.js"
      libpath="../lib/"
      include="jquery,font-awesome,bootstrap,layer,haoutil,turf,mars3d"
    ></script>

    <link href="css/style.css" rel="stylesheet" />
  </head>

  <body class="dark">
    <!--加载前进行操作提示，优化用户体验-->
    <div id="mask" class="signmask" onclick="removeMask()"></div>

    <div id="mars3dContainer" class="mars3d-container"></div>

    <!-- 面板 -->
    <div class="infoview">
      <input type="button" class="btn btn-primary" value="开始漫游" onclick="startFly()" />
      <input type="button" class="btn btn-primary" value="停止漫游" onclick="stopFly()" />

      其他室内视角：
      <input type="button" class="btn btn-primary" value="教室" onclick="centerAtDX1()" />
      <input type="button" class="btn btn-primary" value="走廊" onclick="centerAtDX2()" />
      <input type="button" class="btn btn-primary" value="楼梯间" onclick="centerAtDX3()" />
    </div>

    <script src="./js/common.js"></script>
    <script type="text/javascript">
      'use script' //开发环境建议开启严格模式

      var map
      var roamLine

      function initMap(options) {
        //合并属性参数，可覆盖config.json中的对应配置
        var mapOptions = mars3d.Util.merge(options, {
          scene: {
            center: {
              y: 31.842655,
              x: 117.251587,
              z: 304.57,
              heading: 358,
              pitch: -59,
              roll: 0,
            },
          },
          control: {
            animation: true, //是否创建动画小器件，左下角仪表
            timeline: true, //是否显示时间线控件
          },
          layers: [
            {
              name: '教学楼',
              type: '3dtiles',
              url: 'http://data.marsgis.cn/3dtiles/bim-daxue/tileset.json',
              position: {
                lng: 117.251229,
                lat: 31.844015,
                alt: 36.2,
              },
              center: {
                y: 31.842655,
                x: 117.251587,
                z: 304.57,
                heading: 358,
                pitch: -59,
                roll: 0,
              },
              maximumScreenSpaceError: 16,
              maximumMemoryUsage: 1024,
              // showClickFeature: true,
              // pickFeatureStyle: {
              //   color: '#00FF00',
              // },
              // popup: 'all',
              show: true,
            },
          ],
        })

        //创建三维地球场景
        map = new mars3d.Map('mars3dContainer', mapOptions)

        //键盘漫游
        map.keyboardRoam.setOptions({
          moveStep: 0.1, //平移步长 (米)。
          dirStep: 50, //相机原地旋转步长，值越大步长越小。
          rotateStep: 0.3, //相机围绕目标点旋转速率，0.3-2.0
          minPitch: 0.1, //最小仰角  0-1
          maxPitch: 0.95, //最大仰角  0-1
        })
        map.keyboardRoam.enabled = true //开启键盘漫游

        //创建矢量数据图层
        var graphicLayer = new mars3d.layer.GraphicLayer()
        map.addLayer(graphicLayer)

        //该数据可以从 基础项目 飞行漫游功能界面操作后单个路线的 保存JSON
        var flydata = {
          name: '室内路线',
          speed: 5,
          positions: [
            [117.25164, 31.843773, 36.68],
            [117.251042, 31.843772, 36.68],
            [117.250613, 31.844058, 36.68],
            [117.250677, 31.844146, 38.68],
            [117.250696, 31.844134, 38.68],
            [117.250657, 31.844098, 40.68],
            [117.250611, 31.84406, 40.68],
            [117.251039, 31.843773, 40.68],
          ],
          camera: {
            type: 'dy',
            followedX: 1,
            followedZ: 0.2,
          },
          offsetHeight: 1.6,
        }

        roamLine = new mars3d.graphic.RoamLine(flydata)
        graphicLayer.addGraphic(roamLine)

        startFly()
      }

      function startFly() {
        //启动漫游
        roamLine.start()
      }

      function stopFly() {
        roamLine.stop()
        haoutil.msg('请鼠标单击地图任意区域后，您再可以键盘按A S D W Q E键控制前后左右, 上下左右键控制旋转, 进行手动漫游。')
      }

      function centerAtDX1() {
        stopFly()
        map.setCameraView({
          y: 31.84371,
          x: 117.251041,
          z: 38.51,
          heading: 56.1,
          pitch: -8.1,
          roll: 0.1,
        })
      }

      function centerAtDX2() {
        stopFly()
        map.setCameraView({
          y: 31.84381,
          x: 117.250991,
          z: 38.41,
          heading: 305.9,
          pitch: -12.3,
          roll: 359.9,
        })
      }

      function centerAtDX3() {
        stopFly()
        map.setCameraView({
          y: 31.843787,
          x: 117.251172,
          z: 41.78,
          heading: 17.2,
          pitch: -9.3,
          roll: 0.1,
        })
      }
    </script>
  </body>
</html>
